package mvp.levelup.spring.reports.writters;

import java.io.FileWriter;

/**
 * Created by Valera on 17.08.2014.
 */
public class FileWritter implements IWritter {
    private static final String FILE_NAME = "report.txt";
    private String path;

    public FileWritter(String path) {
        this.path = path;
    }

    @Override
    public void writeReport(String report) {
        try {
            FileWriter fw = null;
            try {
                fw = new FileWriter(path + FILE_NAME);
                fw.write(report);
            } finally {
                if (fw != null) {
                    fw.flush();
                    fw.close();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
